﻿@using System.Text
@using OA.Model
@using OA.AspNetCore.Html
@using OA.Core.Model
@using OA.Core.Helper

@model OA.Model.Department

@using (Html.BeginForm(FormMethod.Post, htmlAttributes: new { @class = "layui-form", id = "myForm" }))
{
    @Html.AntiForgeryToken()


    <div class="layui-form-item">
        @Html.LabelFor(model => model.ParentDepartmentID, new { @class = "layui-form-label" })
        <div class="layui-input-block ParentDepartmentID">
        </div>
    </div>

    <div class="layui-form-item">
        @Html.LabelFor(model => model.Name, new { @class = "layui-form-label" })
        <div class="layui-input-block">
            @Html.MyEditorFor(model => model.Name)
        </div>
    </div>

    <div class="layui-form-item myRegion">
        @Html.LabelFor(model => model.Sort, new { @class = "layui-form-label" })
        <div class="layui-input-block">
            @Html.MyEditorFor(model => model.Sort)
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <input type="submit" value="提 交" lay-submit="" lay-filter="OAForm" class="layui-btn mySubmit" />
        </div>
    </div>
}
<script type="text/javascript" src="/Member/Home/GetDepartmentAndPosition"></script>
<script type="text/javascript" src="@ViewBag.OssUrl/front/js/department.js"></script>
<script type="text/javascript">
    layui.use(['form', 'layedit', 'autocomplete', 'element', 'layer', 'laydate'], function () {        
        element = layui.element;
        laydate = layui.laydate;
        form.on('select(Department)', function (data) {
            InitDepartment($(".ParentDepartmentID"), data.value);
            InitPosition($("#PositionID"), data.value, 0);
            form.render('select');
        });
        form.on('select(PositionID)', function (data) {
            InitEmployeeByPositionID($("#Sponsor"), data.value, 0);
            form.render('select');
        });
        InitDepartment($(".ParentDepartmentID"), @Model.ParentDepartmentID);
</script>